import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  // @ts-ignore
  persist: {
    enabled: true,
    strategies: [
      {
        storage: localStorage
      }
    ]
  },
  state: () => {
    return {
      user: {} as User | null
    }
  },
  actions: {
    setUser(user: User) {
      this.$state.user = user
    },
    delUser() {
      this.$state.user = null
    }
  }
})
